package com.test39_集合应用;

import com.test39_集合应用.factory.ServiceFactory;
import com.test39_集合应用.service.IHRService;
import com.test39_集合应用.vo.Company;
import com.test39_集合应用.vo.Dept;
import com.test39_集合应用.vo.Emp;
import org.junit.Test;

import java.util.Map;

/**
 * 部门信息查找
 */
public class YootkDemo_02 {

    @Test
    public void test1() {
        IHRService hrService = ServiceFactory.getHRServiceInstance();
        System.out.println("-------------- 【1】获取公司的完整架构 --------------");
        Company company = hrService.init();
        System.out.println(company);
        for (Map.Entry<Long, Dept> deptEntry : company.getDepts().entrySet()) {
            System.out.println("\t|- " + deptEntry.getValue());
            for (Map.Entry<Long, Emp> empEntry : deptEntry.getValue().getEmps().entrySet()) {
                System.out.println("\t\t|- " + empEntry.getValue());
            }
        }
    }

    @Test
    public void test2() {
        IHRService hrService = ServiceFactory.getHRServiceInstance();
        hrService.init();
        System.out.println("-------------- 【2】获取指定部门信息 --------------");
        Dept dept = hrService.findByDept(10L);
        System.out.println(dept);
        for (Map.Entry<Long, Emp> empEntry : dept.getEmps().entrySet()) {
            System.out.println("\t|- " + empEntry.getValue());
        }
    }

    @Test
    public void test3() {
        IHRService hrService = ServiceFactory.getHRServiceInstance();
        hrService.init();
        System.out.println("-------------- 【3】获取指定雇员信息 --------------");
        Emp emp = hrService.findByEmp(7369L);
        System.out.println(emp);
    }
}
